{block name=member_datails}
{if $user.user_id}
	<div class="col-sm-9">
		<div class="panel panel-default" id="infobox">
			<div id="member-summary" class="panel-body{if $user.user_warning} bg-red{/if}">
				<div class="row" id="member-details">
					<div class="col-sm-4">
						<h1>{$user.user_gname} {$user.user_surname}</h1>
						{$address.B.address_line1} <br />
						{$address.B.address_suburb}, {$address.B.address_state}, {$address.B.address_postcode}<br />
						{$user.user_email}<br />
						{$address.B.address_telephone}<br />
						<a href="javascript:void(0)" onclick="displayForm('member-form-wrapper')">编辑</a><br />
									
					</div>
					{assign var='cnt' value=0}
					
					{foreach $students as $student}
						<div class="col-sm-4">
							<h2>{$student.student_name} {$student.student_surname}</h2>
						
							生日: {$student.student_dob|date_format:"%Y-%m-%d"}<br />
							{if $student.student_medical}身体状况: {$student.student_medical}<br />{/if}
							<a href="javascript:void(0)" onclick="displayForm('student-form-wrapper{$cnt++}')">编辑</a><br />
							
						</div>
					{/foreach}
				</div>
				<div class="row">
					<div id="edit-forms">
						<div id="member-form-wrapper" class="col-sm-12 form-wrapper" style="display:none;">
							<h2>编辑会员</h2>
							<form class="form-horizontal" id="member-form" role="form" accept-charset="UTF-8" action="" method="post">
								<input type="hidden" value="UpdateMember" name="action" id="action" /> 
								<input type="hidden" value="/admin/includes/processes/processes-member.php" name="url"/> 
    						<input type="hidden" name="formToken" value="{$token}" />
								{include file='member.tpl'}
								<div class="text-center">
									<button type="button" onclick="$(this).closest('.form-wrapper').hide('slow'); $('#member-details').show('slow');" class="btn btn-default">取消</button>
									<button type="submit" class="btn btn-default side-padding">保存</button>
								</div>
							</form>
						</div>
					
						{assign var='cnt' value=0}
						{foreach $students as $student}
							<div id="student-form-wrapper{$cnt}" class="col-sm-12 form-wrapper" style="display:none;">
								<h2>编辑学生</h2>
								<form class="form-horizontal" id="student-form{$cnt}" data-attr-id="update-student" role="form" accept-charset="UTF-8" action="" method="post">
						      <input type="hidden" value="UpdateStudent" name="action" /> 
						      <input type="hidden" value="/admin/includes/processes/processes-member.php" name="url"/> 
						      <input type="hidden" name="formToken" value="{$token}" />
									{include file='student.tpl' cnt=$cnt++}
									<div class="text-center">
										<button type="button" onclick="$(this).closest('.form-wrapper').hide('slow'); $('#member-details').show('slow');" class="btn btn-default">取消</button>
										<button type="button" onclick="if (confirm('Do you want to delete this student?')) { $(this).closest('.form-wrapper').find('input[name=\'action\']').val('DeleteStudent'); $(this).closest('form').submit(); }" class="btn btn-default">删除</button>
										<button type="button" onclick="$(this).closest('.form-wrapper').find('input[name=\'action\']').val('UpdateStudent'); $(this).closest('form').submit();" class="btn btn-default side-padding">保存</button>
									</div>
								</form>
							</div>
						{/foreach}
				</div>
			</div>
		</div>
	</div>
		
	</div> <!--col-sm-9-->
	<div class="col-sm-3">
			<div class="panel panel-default">
				<div class="panel-heading">
					<h4 class="panel-title">操作</h4>
				</div>
				<div class="panel-body">
	  				<!-- <button type="button" class="btn btn-black btn-block">Conver to member</button>
	  				<div class="clearfix"></div><br /> -->
	  			
					<a href="/admin/members/new/{$user.user_id}">报名新课程 / 订单</a><br />
					<a href="/admin/members/buy-merchandise/{$user.user_id}">购买商品</a><br />
					<a href="/admin/members/make-payment/{$user.user_id}">付款</a><br />
					
					<form class="form-horizontal" id="delete-member-form" method="post">
							<input type="hidden" value="DeleteMember" name="action" id="action" /> 
							<input type="hidden" value="/admin/includes/processes/processes-member.php" name="url"/> 
							<input type="hidden" name="formToken" value="{$token}" />
							<input type="hidden" name="user_id" value="{$user.user_id}" />
							<div class="error-alert" style="display:none;">
		          	<div class="alert alert-danger fade in ">
									<button class="close" aria-hidden="true" type="button" onclick="$(this).closest('.error-alert').fadeOut('slow');">&times;</button>
									<strong></strong>
								</div>
		          </div>
	            <div class="success-alert" style="display:none;">
	            	<div class="alert alert-success fade in ">
									<button class="close" aria-hidden="true" type="button"  onclick="$(this).closest('.success-alert').fadeOut('slow');">&times;</button>
									<strong></strong>
								</div>
	            </div>
							{if $admin.level eq 1}<a href="javascript:void(0)" onclick="if (confirm('Do you want to delete this member?')) { $('#delete-member-form').submit(); }">删除会员</a>{/if}
					</form>								
				</div>
			</div>		
	</div>
	<div class="col-sm-12" id="history">
		<h2>历史记录</h2>
		<!-- Nav tabs -->
		<ul id="member-tabs" class="nav nav-tabs" role="tablist">
			<li {if !$user.user_warning && !$request.cartid}class="active"{/if}><a href="#classes" role="tab" data-toggle="tab">课程</a></li>
			<li {if !$user.user_warning && $request.cartid}class="active"{/if}><a id="payments-tab" href="#payments" role="tab" data-toggle="tab">支付</a></li>
			<li><a href="#notes" role="tab" data-toggle="tab">通知</a></li>
			<li id="warning-nav-tab" {if $user.user_warning}class="active bg-red"{/if}><a href="#warnings" role="tab" data-toggle="tab">警告</a></li>
			<li><a href="#emails" role="tab" data-toggle="tab">邮箱</a></li>
		</ul>

		<!-- Tab panes -->
		<div class="tab-content">
			<div class="tab-pane{if !$user.user_warning && !$request.cartid} active{/if}" id="classes">
				
				<!-- MOVE ENROLMENT -->
				<div id="move-enrolment-wrapper" class="form-wrapper" style="display:none;">
					<h3>变更报名</h3>
					<h4 id="move-title"></h4>
					<hr>
					{include file='classterm-filters.tpl' form_id='search-classes-form-move' form_method='post' action='getClasstermpanelTemplate' selectClassOption='move'}
					<form class="form-horizontal" id="move-enrolment-form" method="post">
						<input type="hidden" value="MoveEnrolment" name="action" />
						<input type="hidden" name="formToken" value="{$token}" />
						<input type="hidden" name="student_id" value="" id="move-student"/>
						<input type="hidden" name="old_term_object_id" value="" id="move-term" />
						<input type="hidden" name="old_class_object_id" value="" id="move-class" />
						<div id="search-classes-form-move-result">

						</div>
						<div class="error-alert" style="display:none;">
	          	<div class="alert alert-danger fade in ">
								<button class="close" aria-hidden="true" type="button" onclick="$(this).closest('.error-alert').fadeOut('slow');">&times;</button>
								<strong></strong>
							</div>
	          </div>
						<div class="text-center classterm-btns" style="display:none;">
							<button type="button" onclick="$(this).closest('.form-wrapper').hide('slow'); $('#student-classes-content').show('slow');" class="btn btn-default">取消</button>
							<button type="submit" onclick="" class="btn btn-default">提交</button>
						</div>
					</form>
				</div>
				
				<!-- MAKE-UP CLASS -->
				<div id="make-up-wrapper" class="form-wrapper" style="display:none;">
					<h3>补课</h3>
					<h4 id="make-up-title"></h4>
					<hr>
					{include file='classterm-filters.tpl' form_id='search-classes-form-makeup' form_method='post' action='getClasstermpanelTemplate' selectClassOption='makeup'}
					<form class="form-horizontal" id="make-up-form" method="post">
						<input type="hidden" value="MakeUpClass" name="action" /> 
						<input type="hidden" name="formToken" value="{$token}" />
						<input type="hidden" name="student_id" value="" id="make-up-student"/>
						<input type="hidden" name="old_term_object_id" value="" id="make-up-term" />
						<input type="hidden" name="old_class_object_id" value="" id="make-up-class" />
						<div id="search-classes-form-makeup-result">
							
						</div>
						
						<div class="error-alert" style="display:none;">
	          	<div class="alert alert-danger fade in ">
								<button class="close" aria-hidden="true" type="button" onclick="$(this).closest('.error-alert').fadeOut('slow');">&times;</button>
								<strong></strong>
							</div>
	          </div>
						<div class="text-center classterm-btns" style="display:none;">
							<button type="button" onclick="$(this).closest('.form-wrapper').hide('slow'); $('#student-classes-content').show('slow');" class="btn btn-default">取消</button>
							<button type="submit" onclick="" class="btn btn-default">提交</button>
						</div>
					</form>
				</div>
				
				<!-- MOVE-TRIAL CLASS -->
				<div id="move-trial-wrapper" class="form-wrapper" style="display:none;">
					<h3>变更体验课</h3>
					<h4 id="move-trial-title"></h4>
					<hr>
					{include file='classterm-filters.tpl' form_id='search-classes-form-move-trial' form_method='post' action='getClasstermpanelTemplate' selectClassOption='movetrial'}
					<form class="form-horizontal" id="move-trial-form" method="post">
						<input type="hidden" value="MoveTrialClass" name="action" />
						<input type="hidden" name="formToken" value="{$token}" />
						<input type="hidden" name="student_id" value="" id="move-trial-student"/>
						<input type="hidden" name="old_term_object_id" value="" id="move-trial-term" />
						<input type="hidden" name="old_class_object_id" value="" id="move-trial-class" />
						<div id="search-classes-form-move-trial-result">

						</div>

						<div class="error-alert" style="display:none;">
	          				<div class="alert alert-danger fade in ">
								<button class="close" aria-hidden="true" type="button" onclick="$(this).closest('.error-alert').fadeOut('slow');">&times;</button>
								<strong></strong>
							</div>
						</div>
						<div class="text-center classterm-btns" style="display:none;">
							<button type="button" onclick="$(this).closest('.form-wrapper').hide('slow'); $('#student-classes-content').show('slow');" class="btn btn-default">取消</button>
							<button type="submit" onclick="" class="btn btn-default">提交</button>
						</div>
					</form>
				</div>
				
				<div id="student-classes-content">
					{if $students}
						<div class="panel-group" id="accordion">
							{assign var='cnt' value=0}
							{foreach $students as $student}
								<div class="panel panel-default">
									<div class="panel-heading">
										<h4 class="panel-title">
											<a data-toggle="collapse" data-parent="" href="#student-class{$cnt}">
												{$student.student_name} {$student.student_surname}
											</a>
										</h4>
									</div>
									<div id="student-class{$cnt++}" class="panel-collapse collapse in">
										<div class="panel-body" id="studentclass-wrapper-{$student.student_id}">
											{include file='table-studentclass.tpl'}
										</div>
									</div>
								</div>
							{/foreach}
						</div>
					{else}
						<div class="member-tab-content">
					 		还未报名课程。
					 	</div>
					{/if}
				</div>
			</div>
			<div class="tab-pane{if !$user.user_warning && $request.cartid} active{/if}" id="payments">
				{include file='table-payments.tpl'}
			</div>
			<div class="tab-pane" id="notes">
				<div class="text-right">
					<button type="button" onclick="$('.notes-content').hide('slow'); $('#note-form-wrapper').show('slow');" id="new-note-btn" class="btn btn-black notes-content">New Note</button>
				</div>
				<div id="note-form-wrapper" class="form-wrapper" style="display:none;">
  				<h2>New note</h2>
					<form class="form-horizontal" id="add-note-form" role="form" accept-charset="UTF-8" action="" method="post">
						<input type="hidden" value="AddNewNote" name="action"/> 
						<input type="hidden" value="/admin/includes/processes/processes-member.php" name="url"/> 
 						<input type="hidden" name="formToken" value="{$token}" />
 						<input type="hidden" value="{$user.user_id}" name="user_id"/> 
						<div class="form-group">
				        <label class="col-sm-3 control-label">Content*</label>
				        <div class="col-sm-5">
				        	<textarea class="form-control remove-content" name="notes[note_content]" required></textarea>
				      	</div>
				    </div>
						<div class="col-sm-offset-3 error-alert" style="display:none;">
	          	<div class="alert alert-danger fade in ">
								<button class="close" aria-hidden="true" type="button" onclick="$(this).closest('.error-alert').fadeOut('slow');">&times;</button>
								<strong></strong>
							</div>
	          </div>
						<div class="text-center">
							<button type="button" onclick="$(this).closest('.form-wrapper').hide('slow'); $('.notes-content').show('slow');" class="btn btn-default">Cancel</button>
							<button type="submit" class="btn btn-default">Add Note</button>
						</div>
					</form>
  			</div>
  			<div class="notes-content" id="table-notes-wrapper">
					{include file='table-notes.tpl'}
				</div>
			</div>
			<div class="tab-pane{if $user.user_warning} active{/if}" id="warnings">
				<div class="text-right">
					<button type="button" onclick="$('.warning-content').hide('slow'); $('#warning-form-wrapper').show('slow');" id="warning-btn" class="btn btn-black warning-content">编辑警告</button>
				</div>
				<div id="warning-form-wrapper" class="form-wrapper" style="display:none;">
  				<h2>编辑警告</h2>
					<form class="form-horizontal" id="edit-warning-form" role="form" accept-charset="UTF-8" action="" method="post">
						<input type="hidden" value="UpdateWarning" name="action"/> 
						<input type="hidden" value="/admin/includes/processes/processes-member.php" name="url"/> 
 						<input type="hidden" name="formToken" value="{$token}" />
 						<input type="hidden" value="{$user.user_id}" name="user_id"/> 
						<div class="form-group">
				        <div class="col-sm-12">
				        	<textarea class="form-control" name="user_warning">{$user.user_warning}</textarea>
				      	</div>
				    </div>
						<div class="col-sm-offset-3 error-alert" style="display:none;">
	          	<div class="alert alert-danger fade in ">
								<button class="close" aria-hidden="true" type="button" onclick="$(this).closest('.error-alert').fadeOut('slow');">&times;</button>
								<strong></strong>
							</div>
	          </div>
						<div class="text-center">
							<button type="button" onclick="$(this).closest('.form-wrapper').hide('slow'); $('.warning-content').show('slow');" class="btn btn-default">取消</button>
							<button type="submit" class="btn btn-default">更新</button>
						</div>
					</form>
  			</div>
				<div class="member-tab-content warning-content" id="warning-content-wrapper">
					{if $user.user_warning}
						{$user.user_warning}
					{else}
						没有警告信息。
					{/if}
				</div>
			</div>
			<div class="tab-pane" id="emails">
				<div class="text-right"><!--tinyMCEinit();  -->
					<button type="button" onclick="$('.emails-content').hide('slow'); $('#email-form-wrapper').show('slow');" id="new-email-btn" class="btn btn-black emails-content">新建邮件</button>
				</div>
				<div id="email-form-wrapper" class="form-wrapper" style="display:none;">
	  			<h2>新建邮件</h2>
					<form class="form-horizontal" id="send-email-form" role="form" accept-charset="UTF-8" action="" method="post">
						<input type="hidden" value="SendNewEmail" name="action"/> 
						<input type="hidden" value="/admin/includes/processes/processes-email.php" name="url"/> 
  						<input type="hidden" name="formToken" value="{$token}" />
  						<input type="hidden" value="{$user.user_id}" name="user_id"/>
	  				<div class="form-group">
							<label class="col-sm-3 control-label">To</label>
							<div class="col-sm-5">
								<input class="form-control" type="hidden" name="email" value="{$user.user_email}" >
								<span class="form-control" disabled>{$user.user_email}</span>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">主题*</label>
							<div class="col-sm-7">
								<input class="form-control remove-content" type="text" name="subject" value="" required>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label" >消息*</label>
							<div class="col-sm-5">
								<textarea name="content" class="tinymce remove-content" required>尊敬的 {$user.user_gname|capitalize} &lt;br&gt; &lt;br&gt; 祝好</textarea>
							</div>
						</div>
						<div class="col-sm-offset-3 error-alert" style="display:none;">
	          	<div class="alert alert-danger fade in ">
								<button class="close" aria-hidden="true" type="button" onclick="$(this).closest('.error-alert').fadeOut('slow');">&times;</button>
								<strong></strong>
							</div>
	          </div>
						<div class="text-center">
							<button type="button" onclick="$(this).closest('.form-wrapper').hide('slow'); $('.emails-content').show('slow');" class="btn btn-default">取消</button>
							<button type="submit"  onclick=""  class="btn btn-default">发送邮件</button>
						</div>
					</form>
	  		</div>
	  		<div class="emails-content" id="table-emails-wrapper">
					{include file='table-emails.tpl'}
				</div>
			</div>
		</div>
	</div>


	<script type="text/javascript">
	
		$(function() {
			$('#member-form').validate({
				onkeyup: false
			});
		
			$('#delete-member-form').validate();
			$('#move-enrolment-form').validate();
			$('#make-up-form').validate();
			$('#move-trial-form').validate();
			$('#add-note-form').validate();
			$('#edit-warning-form').validate();
			
			$('#send-email-form').validate({
				onkeyup: false
			});
		
			{assign var='cnt' value=0}
			{foreach $students as $student}
				$("#student-form{$cnt++}").validate({
					onkeyup: false
				});
			{/foreach}

		});
	</script>
{/if}
{/block}
	